home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / wheels1.arc / GETSECTR.LIB < prev    next >
Text File  |  1985-06-28  |  3KB  |  61 lines

  1. {@@@@@@@@@@@ copyright (C) 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@
  2. The purchaser of these procedures and functions may include them in COMPILED
  3. programs freely, but may not sell or give away the source text.
  4.  
  5.     The procedure GetSector receives as parameters the drive, side, track,
  6.     and sector desired, and "R" or "W", for Read or Write.  It either
  7.     reads from or writes to a BUFFER, defined within your program.  The
  8.     buffer should total 512 bytes.  The parameter OKAY is passed back
  9.     to indicate that the operation was successful.
  10.  
  11.     The buffer might just be an array[0..511] of byte, but it could
  12.     also be an array[1..16] of directory_entry_type, or whatever you
  13.     want to read into.  NOTE that it is possible to read more than
  14.     one sector at a time, if you reserve a bigger buffer.  The value
  15.     given to AL is the number of sectors to read.
  16.  
  17.     NOTE that any program that INCLUDEs this file must also INCLUDE
  18.     the type definition in REGPACK.TYP}
  19.  
  20. {OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO}
  21. Procedure GetSector(activity, drive: char;
  22.                  side, sector, track: byte;
  23.                  var OKAY : boolean);
  24.  
  25.   var
  26.       registers  : regpack;
  27.       count      : byte;
  28.       ah,al,ch,cl,dh,dl : byte;
  29.  
  30. begin
  31.     activity := UpCase(activity);
  32.     drive := UpCase(drive);
  33.  
  34.  
  35.     With registers do
  36.       begin
  37.         dl := ord(drive) - 65;  {dl = 0 if drive is A, 1 if B, &c.}
  38.  
  39.           Case activity of             { Set AH for either read or write.    }
  40.               'R': AH := 2;
  41.               'W': AH := 3;
  42.           end;
  43.         count := 0;
  44.  
  45.         repeat
  46.           count := count + 1;
  47.           DH := side;                  { Set the head (side) number.         }
  48.           CH := track;                 { Set the track number.               }
  49.           CL := sector;                { Set starting sector number.         }
  50.           AL := 1;                     { Just read one sector.               }
  51.           ES := Seg(buffer);           { Set segment of buffer.              }
  52.           BX := Ofs(buffer);           { Set offset of buffer.               }
  53.           AX := (ah shl 8) + al;
  54.           CX := (ch shl 8) + cl;
  55.           DX := (dh shl 8) + dl;
  56.           Intr($13,registers);         { Perform the activity.               }
  57.         until (count = 3) or ((AX shr 8) = 0);
  58.         if count = 3 then OKAY := false else OKAY := true;
  59.       end;
  60. end;
  61. {OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO}